Ext.Loader.setConfig( {
	enabled : true
});

Ext.require( [ '*' ]);

Ext.onReady(function() {
	// Define our data model

	var loginPanel = Ext.create('Ext.form.Panel', {
		region : 'center',
		frame : true,
		bodyStyle : 'padding:5px 5px 0',
		width : 350,
		fieldDefaults : {
			msgTarget : 'side',
			labelWidth : 75
		},
		defaultType : 'textfield',
		defaults : {
			anchor : '100%'
		},

		items : [  {
			fieldLabel : 'username',
			id : 'username'
		}, {
			fieldLabel : 'password',
			inputType: 'password',
			id : 'password'
		} ],

		buttons : [ {
			text : 'login',
			handler : function() {
				Ext.Ajax.request({
				    url: 'login/',
				    params:{
						userName:loginPanel.down("#username").getValue(),
						password:loginPanel.down("#password").getValue()
					},
				    success: function(response, opts) {
						if(response.responseText=="success"){
//							location.href =location.host+"/yakaten/";
//							location.href = "http://"+location.host+"/softmarket/manager/downloadPassword/";
							location.href = "http://"+location.host+"/manager/downloadPassword/";
						}else{
						}
				    },
				    failure: function(response, opts) {
				        console.log('server-side failure with status code ' + response.status);
				    }
				});
			}
		}, {
			text : 'Cancel'
		} ]
	})

		Ext.create('Ext.panel.Panel', {
			title : 'welcome ...',
			layout : 'auto',
			items : loginPanel,
			// height : 500,
			renderTo : 'loginarea'
		});
});
